<?php

namespace plugin\admin\app\model\traits;

trait MultiLanguage
{
    protected $defaultLanguage = 'zh';

    protected $currentLanguage = 'zh';

    protected $allowedLanguages = [
        'zh',
        'en',
        'ja',
        'ko',
        'ru',
        'de',
        'fr'
    ];

    public function switchLanguage($language)
    {
        $this->currentLanguage = $language;
        return $this;
    }

    public function switchTable()
    {
        $suffix = '';
        if ($this->currentLanguage != $this->defaultLanguage) {
            $suffix = '_' . $this->currentLanguage;
        }

        $this->table .= $suffix;

        return $this;
    }

}